package com.desktopmng.core.db;

import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.util.StringHelper;


public class PrefixNamingStrategy extends ImprovedNamingStrategy {
	
	private static final long serialVersionUID = 4864477517186230958L;
		
	@Override
	public String classToTableName(String className) {
		return StringHelper.unqualify(className);
	}

	@Override
	public String propertyToColumnName(String propertyName) {
		return propertyName;
	}

	@Override
	public String tableName(String tableName) {
		return Constants.PREFIX + tableName.toUpperCase();
	}

	@Override
	public String columnName(String columnName) {
		return columnName;
	}

	public String propertyToTableName(String className, String propertyName) {
		return Constants.PREFIX + classToTableName(className) + '_' + propertyToColumnName(propertyName);
	}
}
